package com.dekaru.math.type;

public class Complex {

	private double	real;
	private double	imaginary;
	
	
	
	public Complex() {
		
		real = 0d;
		imaginary = 0d;	
	}	

	public Complex(double real, double imaginary) {
		
		this.real = real;
		this.imaginary = imaginary;	
	}
	
	public Complex(Complex obj) {
		
		this.real = obj.getReal();
		this.imaginary = obj.getImaginary();	
	}
	
	
	
	public double getReal() {
	
		return real;	
	}
	
	public double getImaginary() {
	
		return imaginary;	
	}
	
	public void setReal(double real) {
		
		this.real = real;
	}
	
	public void setImaginary(double imaginary) {
		
		this.imaginary = imaginary;
	}
	
	
	
	public Complex add(Complex obj) {
		
		Complex x = new Complex();
		
		x.setImaginary(obj.getImaginary() + getImaginary());
		x.setReal(obj.getReal() + getReal());
		
		return x;
	}
	
	public void add2(Complex obj) {
	
	
		setImaginary(obj.getImaginary() + getImaginary());
		setReal(obj.getReal() + getReal());
	}
	
	public Complex substract(Complex obj) {
		
		Complex x = new Complex();
		
		x.setImaginary(getImaginary() - obj.getImaginary());
		x.setImaginary(getReal() - obj.getReal());
		
		return x;
	}
	
	public Complex multiply(Complex obj) {
	
		Complex x = new Complex();
		
		x.setReal(getReal() * obj.getReal() - getImaginary() * obj.getImaginary());
		x.setImaginary(getReal() * obj.getImaginary() + getImaginary() * obj.getReal());
		
		return x;
	}
}